package com.controller;

import com.entity.User;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Date;

@RestController
public class UserController {
    @RequestMapping("/")
    public User user(){
        return new User(100,"asd",new Date());
    }
    @RequestMapping("/upload")
    public void upload(MultipartFile file){
        Path path = Paths.get("D:\\tmp", file.getOriginalFilename());
        try {
            file.transferTo(path);
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println("上传成功");
    }
}
